<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form label-width="80px">
        <el-form-item label="名字" style="width: 200px" class="filter-item">
          <el-input />
        </el-form-item>
        <el-button v-waves style="margin-left: 20px" class="filter-item" type="primary" icon="el-icon-search">
          查询
        </el-button>
        <el-button v-waves style="margin-left: 20px" class="filter-item" type="primary" icon="el-icon-search" @click="centerDialogVisible = true">
          添加
        </el-button>
      </el-form>

    </div>
    <el-table :data="list" border fit highlight-current-row style="width: 100%">
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-form-item label="标题">
              <span>{{ props.row.id }}</span>
            </el-form-item>
            <el-form-item label="内容">
              <span>{{ props.row.b }}</span>
            </el-form-item>
            <el-form-item label="活动时间">
              <span>{{ props.row.c }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column align="center" label="标题">
        <template slot-scope="{row}">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>

      <el-table-column  label="发布时间">
        <template slot-scope="{row}">
          <span>{{ row.c }}</span>
        </template>
      </el-table-column>
      <el-table-column  label="已查收/接受人数量">
        <template slot-scope="{row}">
          <span>{{ row.num }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="120">
        <template>
          <el-link type="primary">
            修改
          </el-link>
          <el-link style="margin-left: 20px" type="primary">
            删除
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="添加消息"
      :visible.sync="centerDialogVisible"
      width="30%"
    >
      <el-form ref="form" :model="form" label-width="90px">
        <el-form-item label="标题">
          <el-input />
        </el-form-item>
        <el-form-item label="内容">
          <el-input />
        </el-form-item>
        <el-form-item label="添加接收人">
          <el-select placeholder="请选择">
            <el-option label="小明" value="shanghai" />
            <el-option label="王五" value="beijing" />
          </el-select>
        </el-form-item>
        <el-form-item label="活动时间">
          <el-date-picker type="datetime" placeholder="请选择时间" />
        </el-form-item>
        <el-form-item label="发布时间">
          <el-date-picker type="datetime" placeholder="请选择时间" />
        </el-form-item>
      </el-form>
      <el-button style="margin-top: 20px" type="primary" @click="centerDialogVisible = false">确 定</el-button>
    </el-dialog>
  </div>
</template>
<style>
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 80px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }
</style>
<script>
import { fetchList } from '@/api/article'

export default {
  name: 'Meassage',
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'info',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      centerDialogVisible: false,
      list: [
        {
          id: '消息1',
          b: '内容1',
          num: '96/100',
          c: '2020-11-12'
        },
        {
          id: '消息2',
          b: '内容2',
          num: '96/100',
          c: '2020-5-11'
        },
        {
          id: '消息3',
          b: '内容3',
          num: '96/100',
          c: '2020-8-11'
        }
      ],
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10
      }
    }
  },
  methods: {

    cancelEdit(row) {
      row.title = row.originalTitle
      row.edit = false
      this.$message({
        message: 'The title has been restored to the original value',
        type: 'warning'
      })
    },
    confirmEdit(row) {
      row.edit = false
      row.originalTitle = row.title
      this.$message({
        message: 'The title has been edited',
        type: 'success'
      })
    }
  }
}
</script>

<style scoped>
  .edit-input {
    padding-right: 100px;
  }
  .cancel-btn {
    position: absolute;
    right: 15px;
    top: 10px;
  }
</style>
